<template>
	<view class="addpoint">
		<view class="topbar">
			<text class="back" @tap="goback()"> < </text>
			<text>我的收获地址</text>
		</view>
		<uni-card 
		    :title="item.name" 
		    mode="title" 
		    thumbnail="https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/muwu.jpg" 
		    :extra="item.tel" 
			v-for="item in arealist" :key="item.id"
			@tap="toitem(item)"
		>
		    {{item.provinceStr+item.cityStr+item.areaStr+item.cityBak}}
		</uni-card>
		<button @tap="addpoint">新增地址</button>
	</view>
</template>

<script>
	import uniCard from '@/components/uni-card/uni-card.vue'
	import { addresslist } from '../../../api/address/newAddress.js'
	export default {
		components: { uniCard },
		data() {
			return {
				arealist:[],
				name:'',
				tel:'',
				url:'',
				flag:false
			};
		},
		onShow(){
			const value = uni.getStorageSync('userData');
			const userdata = JSON.parse(value)
			addresslist({
				userId:'bdecbb72264e4ec581061d4770a2e914'
			})
			.then(res=>{
				console.log(res)
				this.arealist = res.data.data
			})
		},
		onLoad(option) {
			// console.log(option)
			if(option.num){
				this.flag = true
			}
		},
		methods:{
			toitem(item){
				console.log(item)
				if(this.flag == true){
					uni.navigateTo({
					    url: '/pages/mine/order/orderdetail?addressItem=' + JSON.stringify(item)
					});
				}else{
					uni.navigateTo({
					    url: '/pages/mine/address/item?addressItem=' + JSON.stringify(item)
					});
				}
				
			},
			goback(){
				uni.switchTab({
				    url: '/pages/mine/mine',
				});
			},
			addpoint(){
				uni.navigateTo({
				    url: '/pages/mine/address/item'
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.addpoint{
		position: relative;
		.topbar{
			position: relative;
			left: 0;
			top: 0;
			background-color: #354e44;
			color: #fff;
			width: 100%;
			height: 44px;
			line-height: 44px;
			text-align: center;
			z-index: 998;
			.back{
				font-size: 24px;
				position: absolute;
				left: 20px;
			}
		}
		button{
		    background: rgb(53, 78, 68);
		    color: rgb(255, 255, 255);
			border-radius: 2.5rem;
			box-shadow: 0 0 30px 0 rgba(0,0,0,.2);
			transition: all 0.4s;
		    font-size: 15px;
		    width: 300px;
		    height: 50px;
		    line-height: 50px;
		    text-align: center;
		    margin-left: auto;
		    margin-right: auto;
		    overflow: hidden;
			position: relative;
			top:10px;
		    padding-left: 14px;
		    padding-right: 14px;
		    box-sizing: border-box;
		}
	}
</style>
